#!/usr/bin/perl
# edit.cgi
# Display the ucd-snmp edit page

require 'snmp-lib.pl';

&header($text{'edit_title'}, "", undef, undef, 1);
print "<hr>\n";

&ReadParse();
&error_setup("Edit SystemInfo");

my $sysloc = $in{sysLocation};
my $syscont = $in{sysContact};

$keyElem = "syslocation";
$lineEntry = $keyElem." ".$sysloc;

$Result1 = &WriteConfFile($keyElem,$lineEntry);


$keyElem = "syscontact";
$lineEntry = $keyElem." ".$syscont;

$Result2 = &WriteConfFile($keyElem,$lineEntry);

if($Result1||$Result2)
{
	&error("Failed!");
	&nas_syslog("snmp","naslog_warning",13002,"Edit the Snmp sysinfo failed!");
}
else
{
	print "<b>Successful!</b>";
	&nas_syslog("snmp","naslog_info",13003,"Edit the Snmp sysinfo successful!");
}

##Changed the conf file, now need to restart the agent deamon
my $agentline = `ps -A|grep snmpd`;
#print $agentline;
if($agentline)
{
	$agentline =~ /(\d+)/;
#	print $1;
	kill 9, $1;
}
system "snmpd";
&nas_syslog("snmp","naslog_info",13004,"Restart the snmp daemon after configuration changed!");
##########################################################

&footer("/ucd-snmp/edit.cgi",$text{'edit_title'});
